package zzxkj.blog.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zzxkj
 */
@Configuration
public class RabbitConfig {
    public final static String es_queue = "es_queue";
    public final static String es_bind_key = "es_bind_key";
    public final static String notice_queue = "notice_queue";
    public final static String notice_bind_key = "notice_bind_key";
    public final static String common_exchange = "common_exchange";
    @Bean
    public Queue exQueue() {
        return new Queue(es_queue);
    }
    @Bean
    DirectExchange exChange() {
        return new DirectExchange(common_exchange);
    }

    @Bean
    public Queue noticeQueue(){
        return new Queue(notice_queue);
    }
    @Bean
    DirectExchange noticeChange() {
        return new DirectExchange(common_exchange);
    }

    @Bean
    Binding exBinding(Queue exQueue, DirectExchange exChange) {
        return BindingBuilder.bind(exQueue).to(exChange).with(es_bind_key);
    }
    @Bean
    Binding noticeBinding(Queue noticeQueue, DirectExchange noticeChange) {
        return BindingBuilder.bind(noticeQueue).to(noticeChange).with(notice_bind_key);
    }

}
